package main.java.model;

import java.util.Observable;

public class Handle extends Observable {
    
    private int position;
    
    /**
     * Constructor Handle
     */
    public Handle() {
        //Set to up
        this.position = 0; 
    }
    
    /**
     * Return the position in a string
     * @return String : the position in a string
     */
    public String positionToString() {
        switch (position) {
            case 0 :
                return "Up";
            case 1 :
                return "Down";
            default :
                return "Default";
        }
    }
    
    public void goUp() {
        setPosition(0);
    }

    public void goDown() {
        setPosition(1);
    }

    public int getPosition() {
        return position;
    }

    /**
     * Set Position and notify the main application
     * @param position : the new position
     */
    public void setPosition(int position) {
        this.position = position;
        
        //Setting changes
        setChanged(); 
        //Notify
        notifyObservers(positionToString()); 
    }
}
